/**
* 给一个正整数num，返回小于或等于num的斐波纳契奇数之和。
*/

function sumFibs(num) {
    var arrFibs = [1];
    for(var i=1;i<=num;) {
        arrFibs.push(i);
        i = arrFibs[arrFibs.length-1] + arrFibs[arrFibs.length - 2];
    }

    console.log(arrFibs);

    return arrFibs.reduce(function(prev,curr){
        if(curr%2 !== 0)  return prev + curr;
        else  return prev;
    });
}

console.log(sumFibs(1000));

